package com.example.jetpackcomposelearning

import android.net.Uri
import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.activity.result.contract.ActivityResultContracts
import androidx.activity.viewModels
import com.example.jetpackcomposelearning.compose.ImagePickerScreen
import com.example.jetpackcomposelearning.viewModel.ImagePickerViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class SceneCreationActivity : ComponentActivity() {

        private val viewModel: ImagePickerViewModel by viewModels()

        private val pickMultipleImages =
            registerForActivityResult(ActivityResultContracts.GetMultipleContents()) { uris: List<Uri> ->
                viewModel.saveSelectedImages(uris.map { it.toString() })
            }

        override fun onCreate(savedInstanceState: Bundle?) {
            super.onCreate(savedInstanceState)
            setContent {
                ImagePickerScreen(onPickImagesClick = { pickMultipleImages.launch("image/*") })
            }
        }
    }


